package com.heatup.apt.common.dao;

import com.heatup.apt.model.TSysCity;
import com.heatup.apt.model.TSysCityExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Component;

@Component
public interface TSysCityMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int countByExample(TSysCityExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int deleteByExample(TSysCityExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    @Delete({
        "delete from t_sys_city",
        "where city_ID = #{cityId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long cityId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    @Insert({
        "insert into t_sys_city (city_ID, city_name, ",
        "zip_code, province_ID, ",
        "date_created, date_updated)",
        "values (#{cityId,jdbcType=BIGINT}, #{cityName,jdbcType=VARCHAR}, ",
        "#{zipCode,jdbcType=VARCHAR}, #{provinceId,jdbcType=BIGINT}, ",
        "#{dateCreated,jdbcType=TIMESTAMP}, #{dateUpdated,jdbcType=TIMESTAMP})"
    })
    int insert(TSysCity record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int insertSelective(TSysCity record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    List<TSysCity> selectByExampleWithRowbounds(TSysCityExample example, RowBounds rowBounds);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    List<TSysCity> selectByExample(TSysCityExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    @Select({
        "select",
        "city_ID, city_name, zip_code, province_ID, date_created, date_updated",
        "from t_sys_city",
        "where city_ID = #{cityId,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    TSysCity selectByPrimaryKey(Long cityId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int updateByExampleSelective(@Param("record") TSysCity record, @Param("example") TSysCityExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int updateByExample(@Param("record") TSysCity record, @Param("example") TSysCityExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(TSysCity record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_sys_city
     *
     * @mbggenerated
     */
    @Update({
        "update t_sys_city",
        "set city_name = #{cityName,jdbcType=VARCHAR},",
          "zip_code = #{zipCode,jdbcType=VARCHAR},",
          "province_ID = #{provinceId,jdbcType=BIGINT},",
          "date_created = #{dateCreated,jdbcType=TIMESTAMP},",
          "date_updated = #{dateUpdated,jdbcType=TIMESTAMP}",
        "where city_ID = #{cityId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TSysCity record);


    /**
     * 查询所有城市
     * @return
     */
    List<TSysCity> queryAllCity();

    /**
     * 查询城市ID
     * @param cityName 城市名
     * @param provinceId 省ID
     * @return
     */
    Integer queryCityIdByName(String cityName, Long provinceId);

    /**
     * 查询城市名
     * @param cityId 城市ID
     * @return
     */
    String queryCityNameById(String cityId);
}